package jmine.tec.proxy.chain;

/**
 * Represents an element in an {@link InvocationChain}. Implementation are
 * allowed to alter the return type of method being invoked by returning a
 * different value on the {@link ChainElement#aroundInvoke(InvocationChain)}
 * method.
 * 
 * Instances of this class are encouraged to be serializable.
 * 
 * @author takeshi
 * 
 */
public interface ChainElement {

    /**
     * Hook method to intercept a method invocation.
     * 
     * @param chain
     *            the {@link InvocationChain}
     * @return the object that will be returned
     * @throws Throwable
     *             if a Throwable is thrown
     */
    Object aroundInvoke(InvocationChain chain) throws Throwable;
}
